<?php

namespace App\Http\Resources\OpenShop\InvestmentPromotion;

use App\Library\Rms\RmsMybankApi;
use App\Models\OpenShop\InvestmentPromotion\OpenShopContractTemplateModel;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Cache;

class ContractTemplateListResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            "id"                               => $this->id,
            "templateName"                     => $this->templateName,
            'year'                             => $this->year,
            "initialFee"                       => $this->initialFee,
            "technologyTransferFee"            => $this->technologyTransferFee,
            "deposit"                          => $this->deposit,
            "managementCost"                   => $this->managementCost,
            "managementCostEveryYear"          => $this->managementCostEveryYear,
            "decorationDeposit"                => $this->decorationDeposit,
            "shopCount"                        => $this->shopCount,
            'guidanceFee'                      => $this->guidanceFee,
            'version'                          => $this->version,
            "createdAt"                        => $this->createdAt->timestamp > 0 ? date("Y-m-d H:i:s", $this->createdAt->timestamp) : '',
            "createdByUid"                     => $this->createdByUid,
            "updatedAt"                        => $this->updatedAt->timestamp > 0 ? date("Y-m-d H:i:s", $this->updatedAt->timestamp) : '',
            "updatedByUid"                     => $this->updatedByUid,
            'mode'                             => $this->mode,
            'modeText'                         => OpenShopContractTemplateModel::MODE_MAP_TEXT[$this->mode] ?? "",
//            'brokerageConfig'                          => $getBrokerageConfig,
            'depositAmountRatio'               => $this->depositAmountRatio,
            'monthRealAmountCommissionCapping' => $this->monthRealAmountCommissionCapping,
            'isCommissionCapping'              => $this->isCommissionCapping,
            'amountCommissionCapping'          => $this->amountCommissionCapping,
            'depositAmount'                    => $this->depositAmount,
            'contractTypeV2'                   => $this->contractTypeV2,
        ];
    }
}
